package cn.lysoy.demo.controller;

import cn.lysoy.demo.domain.param.LoginParam;
import cn.lysoy.demo.domain.response.RespBean;
import cn.lysoy.demo.service.IUserService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * 登陆控制
 *
 * @author: lysoy
 * @email: s2295938761@163.com
 * @date: 2022/02/22
 */
@RestController
@RequestMapping("/login")
@Slf4j
@AllArgsConstructor(onConstructor = @__(@Autowired))
public class LoginController {
    private final IUserService userService;


    /**
     * 登陆方法
     *
     * @author: lysoy
     * @email: s2295938761@163.com
     * @date: 2022/02/23
     * @param
     * @return
     */
    @RequestMapping("/doLogin")
    @ResponseBody
    public RespBean doLogin(@Valid LoginParam loginParam, HttpServletRequest request, HttpServletResponse response) {
        return userService.doLogin(loginParam, request, response);
    }
}
